package com.atguigu.controller;

import com.atguigu.pojo.Employee;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: liuaojun
 * @CreateTime: 2025-01-18
 * @Description:
 * @Version: 1.0
 */
@RestController
public class MyRestFulController {
    /**
    * @Author:liuaojun
    * @Date:2025-01-18 14:26
    * @Description：增加信息
    */
    @PostMapping("/emp")
    public Employee add(@RequestBody Employee emp){
        System.out.println("增加emp = " + emp);
        return emp;
    }

    /**
    * @Author:liuaojun
    * @Date:2025-01-18 14:30
    * @Description:修改数据
    */
    @PutMapping("/emp")
    public Employee update(@RequestBody Employee emp){
        System.out.println("修改emp = " + emp);
        return emp;
    }

    /**
    * @Author:liuaojun
    * @Date:2025-01-18 14:33
    * @Description:删除
    */
    @DeleteMapping("/emp/{empId}")
    public String delete(@PathVariable String empId){
        System.out.println("id = " + empId);
        return empId;
    }

    /**
    * @Author:liuaojun
    * @Date:2025-01-18 14:36
    * @Description:查询（id）
    */
    @GetMapping("/emp/{empId}")
    public String selectById(@PathVariable String empId){
        System.out.println("根据ID查询：id = " + empId);
        return empId;
    }

    /**
    * @Author:liuaojun
    * @Date:2025-01-18 14:39
    * @Description:查询
    */
    @GetMapping("emp")
    public String select(){
        System.out.println("查询所有信息");
        return "查询所有信息";
    }

}
